package com.ruoyi.advertising.controller;

import java.util.Date;
import java.util.List;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.advertising.domain.ExpressAdvertising;
import com.ruoyi.advertising.service.IExpressAdvertisingService;
import com.ruoyi.common.core.web.controller.BaseController;

/*
 * 公告Controller
 * 
 * @author ruoyi
 * @date 2024-08-22
 */
@RestController
@RequestMapping("/advertising")
@CrossOrigin
public class ExpressAdvertisingController extends BaseController
{
    @Autowired
    private IExpressAdvertisingService expressAdvertisingService;
    @Autowired
    private RedisTemplate redisTemplate;

    /*
     * 查询公告列表
     */

    /**
     * 处理/list路径的请求，用于获取快递广告的列表数据
     *
     * @param expressAdvertising 快递广告的查询条件，可以为空
     * @return 返回一个TableDataInfo对象，包含了分页后的快递广告列表数据
     */
    @RequestMapping("/list")
    public PageInfo<ExpressAdvertising> list(@RequestBody ExpressAdvertising expressAdvertising)
    {
        PageHelper.startPage(expressAdvertising.getPageNum(), expressAdvertising.getPageSize());
        List<ExpressAdvertising> list = expressAdvertisingService.selectExpressAdvertisingList(expressAdvertising);
        PageInfo<ExpressAdvertising> advertisingPageInfo = new PageInfo<>(list);
        return advertisingPageInfo;
    }

    @RequestMapping("add")
    public void add(@RequestBody ExpressAdvertising expressAdvertising){
        expressAdvertising.setStatus(1);
        expressAdvertising.setCreation(new Date());
        System.out.println("***************************");
        expressAdvertisingService.add(expressAdvertising);
    }
    @RequestMapping("shangjia")
    public void shangjia(@RequestBody ExpressAdvertising expressAdvertising){
        Integer id = expressAdvertising.getId();
        expressAdvertisingService.shangjia(id);
    }
    @RequestMapping("xiajia")
    public void xiajia(@RequestBody ExpressAdvertising expressAdvertising){
        Integer id = expressAdvertising.getId();
        expressAdvertisingService.axiajia(id);
    }
    @RequestMapping("chongxintuisong")
    public void chongxintuisong(@RequestBody ExpressAdvertising expressAdvertising){
        System.out.println(expressAdvertising);
        expressAdvertisingService.congxintuisono(expressAdvertising);
    }
    @RequestMapping("shan")
    public void shan(@RequestBody ExpressAdvertising expressAdvertising){
        Integer id = expressAdvertising.getId();
        expressAdvertisingService.shan(id);
    }
    @RequestMapping("guoqi")
    public void guoqi(@RequestBody ExpressAdvertising expressAdvertising){
        Integer id = expressAdvertising.getId();
        expressAdvertisingService.guoqi(id);
    }
}
